Ext.define('PJ.view.setassessmentpaper.SetEvaluationTime', {
    extend: 'AM.default.DefaultWindowForm',
    requires: ['AM.default.DefaultDateField', 
               'AM.default.DateTime', 
               'AM.default.jsonp.DefaultSubmitJsonp'
               ],
    
    modal: true,// 开启不允许点击其他组件
    frame: true,
    notEdit: true,
    width: 300,
    height: 180,
    isSame: false,
    isEdit: null,

    initComponent: function(){
    	var me = this;
    	me.items= [{
			xtype: 'defaultDate',
			fieldLabel: '评估开始时间',
			name: 'assessCourseStartDay',
			id: 'assessStartTime',
			vtype: 'startLessEndDate',
			startLessEndDate: {
				targetCmpId: 'assessEndTime',
				isStart: true
			},
			emptyText: "请输入评估开始时间",
			labelAlign: 'right',
        	labelWidth: 85
		}, {
			xtype: 'defaultDate',
			fieldLabel: '评估结束时间',
			name: 'assessCourseEndDay',
			id: 'assessEndTime',
			vtype: 'startLessEndDate',
			vtypeText: '结束时间不能早于开始时间！',
			startLessEndDate: {
				targetCmpId: 'assessStartTime',
				isStart: false
			},
			emptyText: "请输入结业时间",
			labelAlign: 'right',
        	labelWidth: 85
		}];
        me.buttons = [{
            text: '确定',
            handler: function(button, event){
                var win = button.up('window');
                win.sub();
            }
        },{
            text: '关闭',
            scope: this,
            handler: this.close
        }];
        me.callParent(arguments);
    },
    listeners: {
    	close: function(win){
    		 this.grid.store.load();
    	}
    },
    sub: function(){
    	var win = this;
    	var form = win.down('form');
    	var baseForm = form.getForm();
    	if (!baseForm.isValid()) {
    		return;
    	}
		var editUrl = win.grid.store.commentUrl;
		if(gj_onlineLearning_constant.loadType == "jsonp"){
			win.down('panel').getForm().doAction("submitJsonp",{
				url: editUrl,
				params: {
					classId:win.classId,
					courseIds:win.courseId
				},
				success: function(f, action){
					if (action.result.success) {
						Ext.Msg.alert('提示', '操作成功！', function(){
							win.grid.getStore().load();
							win.close();
						});
					}else{
						Ext.Msg.alert('提示', action.result.msg, function(){
							win.close();
						});
					}
				},
				failure: function(f, action){
					if (action.result) {
						Ext.Msg.alert('提示', action.result.msg, function(){
							win.close();
						});
					}
					else {
						Ext.Msg.alert('提示', '操作失败！', function(){
							win.close();
						});
					}
				}
			});
		}else{
        	win.submit({
    			url: editUrl,
    			params: {
					classId:win.classId,
					courseIds:win.courseId
				},
        		success: function(f, action){
        			if (action.result.success) {
        				Ext.Msg.alert('提示', '操作成功！', function(){
        					win.grid.getStore().load();
            				win.close();
        				});
        			}else{
        				Ext.Msg.alert('提示', action.result.msg, function(){
        					win.close();
        				});
        			}
        		},
        		failure: function(f, action){
        			if (action.result) {
        				Ext.Msg.alert('提示', action.result.msg, function(){
        					win.close();
        				});
        			}
        			else {
        				Ext.Msg.alert('提示', '操作失败！', function(){
        					win.close();
        				});
        			}
        		}
        	});
        }
    }
});
